package com.shengqin.mapper;

import com.shengqin.entity.Student;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 学生信息 Mapper 接口
 * </p>
 *
 * @author Rui.Zhou
 * @since 2023-12-05
 */
public interface StudentMapper extends BaseMapper<Student> {
    
    /**
     * 统计指定学校下各班级的学生数量
     * @param schoolIds 学校ID列表
     * @return 包含学校ID、班级ID和学生数量的Map列表
     */
    @Select({
        "<script>",
        "SELECT school_id, classes_id, COUNT(*) as student_count",
        "FROM t_student",
        "WHERE school_id IN",
        "<foreach collection='schoolIds' item='id' open='(' separator=',' close=')'>",
        "#{id}",
        "</foreach>",
        "GROUP BY school_id, classes_id",
        "</script>"
    })
    List<Map<String, Object>> countStudentsBySchoolAndClass(@Param("schoolIds") List<Integer> schoolIds);
}
